package top.xiesen.date;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Scanner;

/**	
 * 可视化日历程序
 * @author Allen
 *
 */
public class VisualCalendar {

	public static void main(String[] args) {
		System.out.println("请输入日期(按照格式：2030-1-2)");
		Scanner scanner = new Scanner(System.in);
		String inputStr = scanner.nextLine();
		
		String temp = inputStr;
		DateFormat format = new SimpleDateFormat(temp);
		
		try {
			Date date = format.parse(temp);
			Calendar calendar = new GregorianCalendar();
			calendar.setTime(date);
			
			calendar.set(Calendar.DATE, 1);
			
			int MaxDate = calendar.getActualMaximum(Calendar.DATE);
			System.out.println("日\t一\t二\t三\t四\t五\t六");
			for (int i = 1; i < calendar.get(Calendar.DAY_OF_WEEK); i++) {
				System.out.print("\t");
			}
			
			for (int i = 1; i <= MaxDate; i++) {
				
				System.out.print(i + "\t");
				int w = calendar.get(Calendar.DAY_OF_WEEK);
				if(w == Calendar.SATURDAY){
					System.out.println();
				}
				calendar.add(Calendar.DATE, 1);
			}
			
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
	}
}
